package com.sx.first.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.sx.first.model.Storagetype;


@Repository("storagetypeDAO")
@Scope("prototype")
public class StoragetypeDAO {
	
	private SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	public List<Storagetype> findAll(){
		@SuppressWarnings("unchecked")
		List<Storagetype> list = sessionFactory.getCurrentSession().createQuery("from Storagetype").list();
		return list;
	}
	
	public void save(Storagetype sto){
		sessionFactory.getCurrentSession().save(sto);
	}
	
	public void delete(Storagetype sto){
		sessionFactory.getCurrentSession().delete(sto);
	}
	
	public void update(Storagetype sto){
		sessionFactory.getCurrentSession().update(sto);
	}
	
	public Storagetype findById(int stoId){
		return sessionFactory.getCurrentSession().get(Storagetype.class, stoId);
	}
	

}
